﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;


using ThayerJJ.HCMS.BLL;

public partial class Passback : Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        ClientScript.RegisterClientScriptBlock(this.GetType(), "main_style_file", "<link rel='stylesheet' href='" + Request.ApplicationPath + "/Style/main.css'/>");
    }
    protected void btn_find_Click(object sender, EventArgs e)
    {
        try
        {
            if (txt_username.Text.Trim().Equals(""))
            {
                errinfo.Text = "<font color=red>用户名不能包含空格</font>";
            }

            BLLAdmin blluser = new BLLAdmin();
            DataSet ds = blluser.GetList("username='" + txt_username.Text + "'");
            if (ds.Tables[0].Rows.Count > 0)
            {
                string[] mail = new string[1];
                mail[0] = ds.Tables[0].Rows[0]["email"].ToString();
                string userpass = ds.Tables[0].Rows[0]["Password"].ToString();
                StringBuilder MailBody = new StringBuilder();
                MailBody.Append("<table border='0' width='100%' id='table1'><tr><td>");
                MailBody.Append("请小心保管您的登录名和密码</td></tr><tr><td>");
                MailBody.Append("您的登录名:" + txt_username.Text + "</td></tr><tr><td>");
                MailBody.Append("密码:" + userpass + "</td></tr></table>");
                string MailFrom = "hcms@hubs1.net";
                Function.SendMail(MailBody.ToString(), "HCMS后台管理系统密码找回", mail, MailFrom, "service");
                Response.Write("<script language=javascript>alert('密码信已发出,谢谢使用!');window.location.href='login.aspx'</script>");
            }
            else
            {
                errinfo.Text = "<font color=red>输入的用户名错误,请重新输入</font>";
            }
        }
        catch
        {
            errinfo.Text = "<font color=red>邮件发送失败！</font>";
        }
    }
}
